#include "cmpdef.h"

#include <stdio.h>
#include <iostream>

#include "ntfs.h"
#include "disk.h"
#include "ntfsdump.h"
#include "fstypes.h"
#include "ntfsutils.h"
#include "sxmem.h"

#ifdef CMP_WINDOWS
#include "winntfs.h"
#endif

using namespace std;
using namespace ntfs;
using namespace sx;

int main()//(int argc, char *argv[])
{   
//    (void)argc;
//    (void)argv;

    cout << "aaa" << endl;
    cin.get();


#ifdef CMP_LINUX
    CNTFSVolume disk("/dev/sdb1");
#endif

#ifdef CMP_WINDOWS
    CNTFSVolume disk(L"\\\\.\\C:");
#endif

    CDatadump dump(0x20);

    dumpBootBlock(&disk.mBootBlock);
    cout << "\n\n";

    CMFT mft(&disk);

//    for (int i = 0; ;i++)
    {
        CFileRecord fRec = mft.getFileRecord(6);



        //fRec.getAttribute(AttributeData);
        {
            dump.print(fRec.mBuffer, disk.getFileRecordLength());
            cout << "\n\n";
            dumpFileRec(fRec, true);
            cout << "\n\n";

            SxSharedBuffer data;
            if ( (*fRec.getAttribute(AttributeData))->Nonresident ) 
                data = getAttributeValue( *((CNonResidentAttribute*) fRec.getAttribute(AttributeData)), disk);
            else
                data = getAttributeValue( *((CResidentAttribute*) fRec.getAttribute(AttributeData)));
            
            dump.print(data, data.getSize());

            cout << endl;
            cin.get();
        }
    }

    cin.get();

    return 0;
}
